<!--XOA PHONG BAN-->
<?php
if (isset($_GET['remove']))
{
    $phongbanid = $_GET ['phongbanid'];
    $result = mysql_query("DELETE FROM thanhvien where phongban = $phongbanid; ");
    $result2 = mysql_query("DELETE FROM phongban where phongbanid = $phongbanid; ");
    if ($result2)
        print '<h2>Xóa thành công !</h2>';
}
?>

<!--FORM THEM PHONG BAN-->
<form action="index.php?nhansu&module=phongban" method="post" enctype="multipart/form-data">
<fieldset>
<legend><h1>Thêm mới phòng ban</h1></legend>
<table width="408" border="0">
  <tr>
    <td width="74">Tên phòng ban</td>
    <td width="318"><label>
      <input type="text" name="tenphongban" id="textfield" />
    </label></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><input class="button" type="submit" name="submit" value="Thêm" /></td>
  </tr>
</table>
</fieldset>
</form>

<!--PHP THEM PHONG BAN-->
<?php
if (isset($_POST['submit']))
{
    //print_r ($_POST);
    $tenphongban    =   $_POST['tenphongban'];
    $mysql = "insert into phongban (tenphongban) values ('$tenphongban')";
    $result = mysql_query($mysql);
    if ($result)
        print '<h2>Thành công !</h2>';
}
?>

<!--HIEN THI CAC LOAI PHONG BAN-->
<fieldset>
<legend><h1>Các phòng ban trong tổ chức:</h1></legend>
<table width="695" border="0">
    <tr>
        <td width="100"><b>ID</b></td>
        <td width="300"><b>Tên phòng ban</b></td>
        <!--<td width="200"><b>Xóa</b></td>-->
    </tr>

    <?php
        $phongban = mysql_query("select * from `phongban`");
        while ($row = mysql_fetch_array($phongban))
        {
    ?>
    <tr>
        <td width="100"><?php print "$row[phongbanid]"; ?> </td>
        <td width="200"><?php print "$row[tenphongban]"; ?> </td>
    <!--    <td width="200">
        <a href="index.php?nhansu&module=phongban&phongbanid=<?php print "$row[phongbanid]"; ?>&remove" onclick="return confirm('Xóa phòng ban sẽ xóa tất cả thành viên trong phòng ban ấy, muốn xóa thật ko?')" >Xóa</a>
        </td>
        -->
    </tr>
    <?php 
        }
    ?>
</table>
</fieldset>
